package utils

import (
	"github.com/duke-git/lancet/v2/convertor"
	"github.com/duke-git/lancet/v2/cryptor"
	"github.com/duke-git/lancet/v2/random"
	"github.com/goravel/framework/support/str"
	"math/rand"
	"time"
)

// MailsDomains 可用的邮箱域名列表
func MailsDomains() []string {
	return []string{"gmail.com", "yahoo.com", "hotmail.com", "outlook.com", "aol.com", "sohu.com", "qq.com", "huan.tv"}
}

// MockPhoneNumber 生成随机手机号
func MockPhoneNumber() string {
	return convertor.ToString(random.RandInt(13300000000, 13399999999))
}

// MockMd5Password 生成随机密码
func MockMd5Password() string {
	return cryptor.Md5String(random.RandString(8))
}

// MockEmail 生成随机邮箱
func MockEmail(name string) string {
	rand.NewSource(time.Now().UnixNano())
	domains := MailsDomains()
	number := rand.Intn(len(domains))
	domain := domains[number]
	if name == "" {
		nameLength := rand.Intn(4) + 6
		name = random.RandString(nameLength)
	}
	name = str.Of(name).Lower().String()
	return name + "@" + domain
}
